export default {
  lazyImg: {
    mounted (dom, option) {
      const io = new IntersectionObserver(
        function ([{ isIntersecting }]) {
          if (isIntersecting) {
            dom.src = option.value
          }
          if (!isIntersecting && dom.src.length > 0) {
            io.unobserve(dom)
            io.disconnect()
          }
        },
        {
          threshold: [0]
        }
      )
      io.observe(dom)
    },

    beforeUnmount (dom, option) {}
  }
}
